.TH "Slurm API" "3" "Slurm partition information functions" "May 2017" "Slurm partition information functions"

.SH "NAME"
slurm_free_partition_info_msg, slurm_load_partitions,
slurm_print_partition_info, slurm_print_partition_info_msg
\- Slurm partition information reporting functions
.SH "SYNTAX"
.LP
#include <stdio.h>
.br
#include <slurm/slurm.h>
.LP
void \fBslurm_free_partition_info_msg\fR (
.br
	partition_info_msg_t *\fIpartition_info_msg_ptr\fP
.br
);
.LP
int \fBslurm_load_partitions\fR (
.br
	time_t \fIupdate_time\fR,
.br
	partition_info_msg_t **\fIpartition_info_msg_pptr\fP,
.br
	uint16_t \fIshow_flags\fP
.br
 );
.LP
void \fBslurm_print_partition_info\fR (
.br
	FILE *\fIout_file\fP,
.br
	partition_info_t *\fIpartition_ptr\fP,
.br
	int \fIone_liner\fP
.br
);
.LP
void \fBslurm_print_partition_info_msg\fR (
.br
	FILE *\fIout_file\fP,
.br
	partition_info_msg_t *\fIpartition_info_msg_ptr\fP,
.br
	int \fIone_liner\fP
.br
);
.SH "ARGUMENTS"
.LP
.TP
\fIone_liner\fP
Print one record per line if non\-zero.
.TP
\fIout_file\fP
Specifies the file to print data to.
.TP
\fIpartition_info_msg_pptr\fP
Specifies the double pointer to the structure to be created and filled with the time
of the last partition update, a record count, and detailed information about each
partition. Detailed partition information is written to fixed sized records and includes:
name, state, job time limit, job size limit, node names, indexes into the node table,
etc. In the case of indexes into the node table, this is an array of integers with
pairs of start and end index number into the node information records and the
data is terminated with a value of \-1. See slurm.h for full details on the data
structure's contents.
.TP
\fIpartition_info_msg_ptr\fP
Specifies the pointer to the structure created by \fBslurm_load_partitions\fP.
.TP
\fIshow_flags\fP
Job filtering flags, may be ORed.
Information about partitions that are configured as
hidden and partitions that the user's group is unable to utilize
are not reported by default.
The \fBSHOW_ALL\fP flag will cause information about partitions
to be displayed.
Only information about partitions on the local cluster will be returned unless
the cluster is in a federation and the \fBSHOW_ALL\fP flag is set.

.TP
\fIupdate_time\fP
For all of the following informational calls, if update_time is equal to or greater
than the last time changes where made to that information, new information is
not returned.  Otherwise all the configuration. job, node, or partition records
are returned.
.SH "DESCRIPTION"
.LP
\fBslurm_free_partition_info_msg\fR Release the storage generated by the
\fBslurm_load_partitions\fR function.
.LP
\fBslurm_load_partitions\fR Returns a partition_info_msg_t that contains an
update time, record count, and array of partition_table records for all partitions.
.LP
\fBslurm_print_partition_info\fR Prints the contents of the data structure describing a
single partition records from the data loaded by the \fBslurm_load_partitions\fR function.
.LP
\fBslurm_print_partition_info_msg\fR Prints the contents of the data structure describing
all partition records loaded by the \fBslurm_load_partitions\fR function.
.SH "RETURN VALUE"
.LP
On success, zero is returned. On error, \-1 is returned, and Slurm error code is set appropriately.
.SH "ERRORS"
.LP
\fBSLURM_NO_CHANGE_IN_DATA\fR Data has not changed since \fBupdate_time\fR.
.LP
\fBSLURM_PROTOCOL_VERSION_ERROR\fR Protocol version has changed, re\-link
your code.
.LP
\fBSLURM_PROTOCOL_SOCKET_IMPL_TIMEOUT\fR Timeout in communicating with
Slurm controller.
.SH "EXAMPLE"
.LP
#include <stdio.h>
.br
#include <stdlib.h>
.br
#include <slurm/slurm.h>
.br
#include <slurm/slurm_errno.h>
.LP
int main (int argc, char *argv[])
.br
{
.br
	int i;
.br
	partition_info_msg_t *part_info_ptr = NULL;
.br
	partition_info_t *part_ptr;
.LP
	/* get and dump some partition information */
.br
	if (slurm_load_partitions((time_t)NULL,
.br
	                          &part_info_ptr, SHOW_ALL)) {
.br
		slurm_perror ("slurm_load_partitions error");
.br
		exit (1);
.br
	}
.LP
	/* The easy way to print... */
.br
	slurm_print_partition_info_msg (stdout,
.br
	                                part_info_ptr, 0);
.LP
	/* A harder way.. */
.br
	for (i = 0; i < part_info_ptr\->record_count; i++) {
.br
		part_ptr = &part_info_ptr\->partition_array[i];
.br
		slurm_print_partition_info(stdout, part_ptr, 0);
.br
	}
.LP
	/* The hardest way. */
.br
	printf("Partitions updated at %lx, records=%d\\n",
.br
	       part_info_ptr\->last_update,
.br
	       part_info_ptr\->record_count);
.br
	for (i = 0; i < part_info_ptr\->record_count; i++) {
.br
		printf ("PartitionName=%s Nodes=%s\\n",
.br
			part_info_ptr\->partition_array[i].name,
.br
			part_info_ptr\->partition_array[i].nodes );
.br
	}
.LP
	slurm_free_partition_info_msg (part_info_ptr);
.br
	exit (0);
.br
}

.SH "NOTES"
These functions are included in the libslurm library,
which must be linked to your process for use
(e.g. "cc \-lslurm myprog.c").
.LP
Some data structures contain index values to cross\-reference each other.
If the \fIshow_flags\fP argument is not set to SHOW_ALL when getting this
data, these index values will be invalid.
.LP
The \fBslurm_hostlist_\fR functions can be used to convert Slurm node list
expressions into a collection of individual node names.

.SH "COPYING"
Copyright (C) 2002\-2006 The Regents of the University of California.
Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
CODE\-OCEC\-09\-009. All rights reserved.
.LP
This file is part of Slurm, a resource management program.
For details, see <https://slurm.schedmd.com/>.
.LP
Slurm is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
.LP
Slurm is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
details.

.SH "SEE ALSO"
.LP
\fBscontrol\fR(1), \fBsinfo\fR(1), \fBsqueue\fR(1),
\fBslurm_hostlist_create\fR(3), \fBslurm_hostlist_shift\fR(3),
\fBslurm_hostlist_destroy\fR(3),
\fBslurm_get_errno\fR(3), \fBslurm_load_node\fR(3),
\fBslurm_perror\fR(3), \fBslurm_strerror\fR(3)

